home *** CD-ROM | disk | FTP | other *** search
- // OpenGLRainbows.h: Schnittstelle fⁿr die Klasse OpenGLRainbows.
- //
- //////////////////////////////////////////////////////////////////////
-
- #if !defined(AFX_OPENGLRAINBOWS_H__266EBDA0_35ED_11D4_9493_F737DDF20444__INCLUDED_)
- #define AFX_OPENGLRAINBOWS_H__266EBDA0_35ED_11D4_9493_F737DDF20444__INCLUDED_
-
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
-
-
- #ifndef OPENGL_RAINBOWS_INCLUDED_09_12_2000_16_15
- #define OPENGL_RAINBOWS_INCLUDED_09_12_2000_16_15
-
- #ifdef _WINDOWS_
- #include "windows.h"
- #else
- #include "afxwin.h"
- #endif
- #include <gl\gl.h> // Header File For The OpenGL32 Library
- #include <gl\glu.h> // Header File For The GLu32 Library
- #include <gl\glaux.h> // Header File For The Glaux Library
-
- #include "GFFileSystem.h"
- #include <mmsystem.h>
-
- #define GLR_OK 0x0000
- #define GLR_MAX_TEXTURES 0x00FF
- #define GLR_MAX_SURFACE 0x000F
- #define GLR_MAX_PARTICLE 0x0400
-
-
- #define MAKEGRAYCOLOR(a) {int b=(int)((GetRValue(a)*0.30) + (GetGValue(a)*0.59) + (GetBValue(a)*0.11)); a=RGB(b,b,b);}
- #ifndef ZeroStruct
- #define ZeroStruct(a) ::memset(&a, 0, sizeof(a))
- #endif
-
- struct OPENGL_PARTICLE
- {
- int amount; // Amount of Particles to Create
- int type; // 0-Triangluar
- float age; // in 1/1000 sec
- float speedx; // in pixels/1/1000 sec
- float speedy; // in pixels/1/1000 sec
- float movex; // Additional Movement X - Wind
- float movey; // Additional Movement Y - Gravity
- float accx; // accellerate X
- float accy; // accellerate Y
- float posx; // Position
- float posy; // Position
-
- float c_red; // Red [0; 0.5]
- float c_green; // Green [0; 0.5]
- float c_blue; // Blue [0; 0.5]
- };
-
- struct OPENGL_SPRITEFX
- {
- // SpriteFX
- float alpha;
- float angle;
- short dx;
- short dy;
- COLORREF teint;
- };
-
- extern float qsin[360];
- extern float qcos[360];
-
-
- class OpenGLRainbows
- {
- /////////////////////////////////////////////////////////////////////////////////////////
- // FUNCTIONS
- /////////////////////////////////////////////////////////////////////////////////////////
- public:
- OpenGLRainbows();
- virtual ~OpenGLRainbows();
-
- HRESULT Init(HWND hwnd, int width, int height, int bpp, unsigned short fps=5); // Init OpenGLRainbows. Returns GLR_OK if OK.
- bool IsActive() {return m_IsActive;} // Can perform rendering?
- bool DoFullscreen();
- bool DoWindowed();
- bool HideWindow();
- unsigned short ConstFlip() {return m_ConstFlip;}
- void ChangeSize(GLsizei w, GLsizei h);// Change viewing volume and viewport. Called when window is resized
-
- private:
- void SetupRC(void); // Initialize the Rendering Context
- void SetDCPixelFormat(HDC hDC); // Set Pixel Format function - forward declaration
- HPALETTE GetOpenGLPalette(HDC hDC); // For Palettized Viewport...
-
- // Sprite Operations
- ///////////////////////////////////////////////////////////////////
- public:
-
- BOOL LoadSprite(GLuint num, LPCTSTR szFileName, COLORREF colorkey); // Load a Texture as a Sprite
-
- void DrawSprite(short num, short x, short y); // Draws a Single Sprite with Cookie
- void ZoomSprite(short num, short x, short y, short wx, short wy); // Zooms Sprite to new extents
- void RotoSprite(short num, short x, short y, short angle);// Draws a Sprite with Rotation
-
- void DrawSpriteNC(short num, short x, short y); // Draws a Single Sprite with NO Cookie
- void ZoomSpriteNC(short num, short x, short y, short wx, short wy); // Zooms Sprite to new extents NO Cookie
- void RotoSpriteNC(short num, short x, short y, short angle);// Draws a Sprite with Rotation NO Cookie
-
- void DrawSpriteAB(short num, short x, short y, GLfloat alpha); // Draws a Single Sprite with AlphaBlending
- void ZoomSpriteAB(short num, short x, short y, short wx, short wy, GLfloat alpha); // Zooms Sprite to new extents Alpha Blending
- void RotoSpriteAB(short num, short x, short y, short angle, GLfloat alpha);// Draws a Sprite with Rotation with Alpha Blending
-
- void DrawSpriteFX(short num, short x, short y, OPENGL_SPRITEFX& fx); // Draw Sprotes with FX
-
- bool LoadSurface(GLuint num, LPCTSTR szFileName, bool GrayScale=false); // Load a Background Surface
- void PasteSurface(GLuint num, short scx=0, short scy=0); // Show a Background Surface
-
- void Particles(OPENGL_PARTICLE& pt, COLORREF color=0); // Add Partikels, No Color will use struct-values
- void DrawParticles(); // Call to draw particles if any required
- inline unsigned short FlipScreens(void); // Flip Screens, Kill WinMessages, Return Elapsed Time
-
-
- /////////////////////////////////////////////////////////////////////////////////////////
- // DATA
- /////////////////////////////////////////////////////////////////////////////////////////
- public:
- void ResizeAuto();
- void BlendToSurface(int fsurface, int tsurface);
- void FreeAll();
- void FreeSurface(int num);
- void FreeSprite(int num);
- void GrabSurface(int num);
- void DrawLine(short sx, short sy, short ex, short ey, COLORREF col);
- HPALETTE hPalette;
-
- GLshort SpriteX[GLR_MAX_TEXTURES]; // TexSize X
- GLshort SpriteY[GLR_MAX_TEXTURES]; // TexSize Y
- GLshort SpriteBX[GLR_MAX_TEXTURES]; // BmpSize X
- GLshort SpriteBY[GLR_MAX_TEXTURES]; // BmpSize Y
- GLshort SpriteDX[GLR_MAX_TEXTURES]; // Offset X
- GLshort SpriteDY[GLR_MAX_TEXTURES]; // Offset Y
- struct OPENGL_RAINBOWS_WINDOW
- {
- HWND hwnd;
- int width;
- int height;
- int bpp;
- bool fullscreen;
- } m_WND;
-
- private:
- struct OPENGL_RAINBOWS_SURFACE
- {
- GLuint txt [64][64]; // Textures
- GLushort sizx[64][64]; // Size of each Texture X
- GLushort sizy[64][64]; // Size of each Texture Y
- // GLushort offy; //
- GLubyte usex; // Used Texture-Panels X
- GLubyte usey; // Used Texture-Panels Y
- } m_Surface[GLR_MAX_SURFACE];
-
-
-
- bool m_IsActive; // Can perform Rendering
- HGLRC m_hRC; // Permenant Rendering context
- GLuint Texture[GLR_MAX_TEXTURES]; // Texture
- DWORD m_LastTime;
- unsigned short m_FrameRate;
- unsigned short m_LastFlip;
- unsigned short m_ConstFlip;
-
- OPENGL_PARTICLE m_Particle[GLR_MAX_PARTICLE];
- int m_CurrParticle;
- };
-
- #endif // !defined(AFX_OPENGLRAINBOWS_H__266EBDA0_35ED_11D4_9493_F737DDF20444__INCLUDED_)
-
- #endif //#define OPENGL_RAINBOWS_INCLUDED_09_12_2000_16_15
-
- //////////////////////////////////////////////////////////////////////////////////////////
- // I N L I N E S
- //////////////////////////////////////////////////////////////////////////////////////////
-
-
- //---------------------------------------------------------------//
- unsigned short OpenGLRainbows::FlipScreens(void)
- //---------------------------------------------------------------//
- {
- DWORD now;
- MSG m;
- SwapBuffers(::GetDC(m_WND.hwnd));
- glClear(GL_COLOR_BUFFER_BIT);
- m_LastFlip=0;
- while (m_LastFlip<m_FrameRate)// Slow to xx Hz !?
- {
- now=timeGetTime();
- m_LastFlip+=(unsigned short)(now-this->m_LastTime);
- this->m_LastTime=now;
-
- // Peek & Translate Win Message
- if (::PeekMessage(&m, this->m_WND.hwnd, 0, 0, PM_REMOVE))
- {
- if (m.message==WM_SYSCOMMAND && m.wParam==SC_CLOSE) return 0;
- ::DispatchMessage(&m);
- ::DefWindowProc(this->m_WND.hwnd, m.message, m.wParam, m.lParam);
- }
- }
- return m_LastFlip;
- }
-
-
-